<template>
	<view>
		<h1>我是用户中心</h1>
		<button type="default" @click="testSchema">添加对象</button>
		<button type="default" @click="toInfoByUniPage">info</button>
	</view>
</template>
<script>
	let db = uniCloud.database()
	export default {
		data() {
			return {
				anGoodsData: {
					contact_infomation: '18899998888',
					content: '我是大晒比',
					create_time: "2022-11-22"
				}
			};
		},
		async mounted() {
			this.login()
		},
		methods: {
			toInfoByUniPage() {
				uni.navigateTo({
					url: "/uni_modules/uni-id-pages/pages/login/login-withpwd",
				})
			},
			async login() {
				let res = await new Promise((resolve, reject) => {
					uni.login({
						provider: 'weixin',
						success: (res) => {
							resolve(res)
						}
					})
				})
				//目前没问题
				let data = await uniCloud.importObject('users').login(res)
				console.log(data);
			},
			async testSchema() {
				// let res = await uniCloud.callFunction({
				// 	name: 'anTest',
				// 	data: this.anGoodsData
				// })
				// let obj = await db.collection('test').doc(res.result.id).get()
				// console.log(obj);

				let order = db.collection('songshu-orders').where('goods_id == "49"').getTemp()
				let goods = db.collection('songshu-goods').getTemp()
				db.collection(order, goods).get().then(res => {
					console.log(res);
				})
			}
		}
	}
</script>

<style lang="less">

</style>
